sysroot: Support boot counting for boot entries
authorIgor Opaniuk <igor.opaniuk@foundries.io>
Wed, 11 Sep 2024 16:03:10 +0000 (18:03 +0200)
committerIgor Opaniuk <igor.opaniuk@foundries.io>
Thu, 10 Jul 2025 06:58:19 +0000 (08:58 +0200)
commit08487091256b93493f8d692e37ab3d892c758da1
tree6dc4665c8dbb71d02a997c98baff3b003379ea4d
parent23113fbfb6dae92a80e3495d6688caa4196b3e9a
sysroot: Support boot counting for boot entries

Add support for boot counting for bootloader entries [1].
The boot counting data is stored in the name of the boot loader entry.
A boot loader entry file name may contain a plus (+) followed by a number.
This may optionally be followed by a minus (-) followed by a second number.
The dot (.) and file name suffix (conf or efi) must immediately follow.

The feature is enabled via sysroot configuration:
[sysroot]
boot-counting-tries=3

Testing:
$ ostree admin deploy 91fc19319be9e79d07159303dff125f40f10e5c25614630dcbed23d95e36f907
Copying /etc changes: 2 modified, 3 removed, 4 added
bootfs is sufficient for calculated new size: 0 bytes
Transaction complete; bootconfig swap: yes; bootversion: boot.0.1, deployment count change: 1

$ ls /boot/loader/entries
ostree-1.conf  ostree-2+3.conf

[1] https://uapi-group.org/specifications/specs/boot_loader_specification/#boot-counting
Signed-off-by: Igor Opaniuk <igor.opaniuk@foundries.io>
Signed-off-by: Colin Walters <walters@verbum.org>
13 files changed:
Makefile-libostree.am
Makefile-tests.am
apidoc/ostree-sections.txt
man/ostree.repo-config.xml
src/libostree/libostree-devel.sym
src/libostree/ostree-bootconfig-parser-private.h [new file with mode: 0644]
src/libostree/ostree-bootconfig-parser.c
src/libostree/ostree-bootconfig-parser.h
src/libostree/ostree-repo-private.h
src/libostree/ostree-repo.c
src/libostree/ostree-sysroot-deploy.c
tests/test-admin-boot-counting-tries.sh [new file with mode: 0755]
tests/test-bootconfig-parser-internals.c [new file with mode: 0644]